<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //----------------------------------------------------------------------------------------
      // var a = 20;
      // function fn() {
      //   function foo() {
      //     console.log(this.a);
      //   }
      //   foo();
      // }
      // fn();
      //----------------------------------------------------------------------------------------
      var obj = {
        a: 20,
        getA: function () {
          setTimeout(function () {
            console.log(this.a);
          }, 1000);
        },
      };

      obj.getA();
    </script>
  </body>
</html>
